package com.icss.ah.designatedSales.action;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;

import com.icss.ah.base.action.BaseAction;
import com.icss.ah.base.bean.EasyuiDataGridJson;
import com.icss.ah.login.bean.UserInfoBean;

@Controller
public class DesignatedSalesAction extends BaseAction {

	private static final long serialVersionUID = 4198659102514180464L;
	
	private EasyuiDataGridJson dataGridJson = new EasyuiDataGridJson();
	
	private String productId;
	private String productName;
	private String queryName;
	private String queryCode;
	private String licenceNoStr;
	private String uuidStr;
	
	public String toDesignatedSalesListPage(){
		return "toDesignatedSalesListPage";
	}
	
	public void queryDesignatedSalesList(){
		String userCode=getUserCodeFromSession();
		UserInfoBean userInfo=getUserInfo(userCode);
		String corpId = userInfo.getCorpId();
		String shopId=userInfo.getShopId();
		Map<String, String> map = new HashMap<String, String>();
		map.put("corpId", corpId);
		map.put("shopId", shopId);
		map.put("productName", productName);
		map.put("queryName", queryName);
		map.put("startIndex", getStartIndexMysql());
		map.put("rowNums", getEndIndexMysql());
		dataGridJson = designatedSalesService.queryDesignatedSalesList(map);
		str2Resp(JSONObject.fromObject(dataGridJson).toString());
	}
	
	public String toClientInfoListPage(){
		getRequest().setAttribute("productId", productId);
		return "toClientInfoListPage";
	}
	
	public void queryClientInfoList(){
		Map<String, String> map = new HashMap<String, String>();
		map.put("queryName", queryName);
		map.put("queryCode", queryCode);
		map.put("productId", productId);
		map.put("startIndex", getStartIndexMysql());
		map.put("rowNums", getEndIndexMysql());
		dataGridJson = designatedSalesService.queryClientInfoList1(map);
		str2Resp(JSONObject.fromObject(dataGridJson).toString());
	}
	
	public void saveClientInfo(){
		String userCode=getUserCodeFromSession();
		UserInfoBean userInfo=getUserInfo(userCode);
		String corpId = userInfo.getCorpId();
		String shopId=userInfo.getShopId();
		String result = designatedSalesService.saveClientInfo(corpId, shopId, productId, licenceNoStr);
		str2Resp(result);
	}
	
	public String toBuyerInfoPage(){
		getRequest().setAttribute("productId", productId);
		return "toBuyerInfoPage";
	}
	
	public void queryBuyerInfoList(){
		Map<String, String> map = new HashMap<String, String>();
		map.put("queryName", queryName);
		map.put("queryCode", queryCode);
		map.put("productId", productId);
		map.put("startIndex", getStartIndexMysql());
		map.put("rowNums", getEndIndexMysql());
		dataGridJson = designatedSalesService.queryBuyerInfoList(map);
		str2Resp(JSONObject.fromObject(dataGridJson).toString());
	}
	
	public void delDesignatedSalesInfo(){
		String result = designatedSalesService.delDesignatedSalesInfo(uuidStr);
		str2Resp(result);
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getQueryName() {
		return queryName;
	}

	public void setQueryName(String queryName) {
		this.queryName = queryName;
	}

	public String getQueryCode() {
		return queryCode;
	}

	public void setQueryCode(String queryCode) {
		this.queryCode = queryCode;
	}

	public String getLicenceNoStr() {
		return licenceNoStr;
	}

	public void setLicenceNoStr(String licenceNoStr) {
		this.licenceNoStr = licenceNoStr;
	}

	public String getUuidStr() {
		return uuidStr;
	}

	public void setUuidStr(String uuidStr) {
		this.uuidStr = uuidStr;
	}

}
